@echo off

if "%1" neq "r" (goto joke) else (goto restore)

:joke

mkdir "%APPDATA%\JokeSounds"
copy "%~dp0\YameteKudasai.wav" "%APPDATA%\JokeSounds\YameteKudasai.wav"
copy "%~dp0\Ahh.wav" "%APPDATA%\JokeSounds\Ahh.wav"

reg add "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceConnect\.Current" /ve /d "%APPDATA%\JokeSounds\YameteKudasai.wav" /t REG_SZ /f
reg add "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceDisconnect\.Current" /ve /d "%APPDATA%\JokeSounds\Ahh.wav" /t REG_SZ /f

goto end

:restore

rmdir "%APPDATA%\JokeSounds" /s /q

reg copy "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceConnect\.Default" "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceConnect\.Current" /f
reg copy "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceDisconnect\.Default" "HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\DeviceDisconnect\.Current" /f

goto end

:end
